#include<bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;
char a[105][105];
int n;
int f;
int st[105][105];
int sx[10]={-1,-1,-1,0,0,1,1,1}, sy[10]={-1,0,1,-1,1,-1,0,1};
queue<P> q;
void bfs()
{
	q.push(P(1,1));
	st[1][1] = 1;
	while(q.size())
	{
		P p = q.front();
		q.pop();
		if(p.first == 2 && p.second == n)
		{
			f = 1;
			break;
		}
		for(int i = 0; i <= 7; i++)
		{
			int xx = p.first + sx[i], xy = p.second + sy[i];
			if(xx >= 1 && xx <= 2 && xy >= 0 && xy <= n && st[xx][xy] == 0 && a[xx][xy] == '0')
			{
				q.push(P(xx,xy));
				st[xx][xy] = 1;
			}
		}
	}
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		while(q.size())
		{
			q.pop();
		}
		memset(a,0,sizeof(a));
		memset(st,0,sizeof(st));
		cin>>n;
		f = 0;
		for(int i = 1; i <= 2; i++)
		{
			for(int j = 1; j <= n; j++)
			{
				cin>>a[i][j];
			}
		}
		bfs();
	
		if(f == 1)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
}
